import * as THREE from 'three'
import { GUI } from 'three/addons/libs/lil-gui.module.min.js'
import { ColorGUIHelper } from './GUIHelper'

export const addHemisphereLight = function ({
  skyColor = 0xffffff,
  groundColor = 0x000000,
  intensity = 1,
  gui = false,
  scene = window.threeScene,
} = {}) {
  const light = new THREE.HemisphereLight(skyColor, groundColor, intensity)
  if (gui) {
    const container = document.querySelector('.gui-list')
    const g = new GUI({ title: 'HemisphereLight', container })
    g.addColor(new ColorGUIHelper(light, 'color'), 'value').name('skyColor')
    g.addColor(new ColorGUIHelper(light, 'groundColor'), 'value').name('groundColor')
    g.add(light, 'intensity', 0, 5, 0.01)
  }
  scene.add(light)
  return light
}
